<%-- 
    Document   : statistic
    Created on : May 1, 2013, 5:53:56 PM
    Author     : 52571783
--%>
<%@page import="entity.connector.HouseConnector"%>
<%@page import="entity.bean.ShowStatistic"%>
<%@page import="entity.bean.Show"%>
<%@page import="entity.bean.Show"%>
<%@page import="entity.bean.Movie"%>
<%@page import="entity.connector.ShowDownloader"%>
<%@page import="entity.connector.MovieDownloader"%>
<%@page import="entity.bean.HouseStatistic"%>
<%@page import="entity.connector.StatisticProvider"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Statistic</title>
    </head>
    <body>
        <h1>Statistics</h1>
        <%
            HouseStatistic houseStatistic;
            ShowDownloader showDownloader;
            Show[] show;
            int noOfHouse = HouseConnector.getNoOfHouses();
            int noOfShow;
            ShowStatistic showStatistic;
        %>
    <% for (int i = 1; i <= noOfHouse; i++) {
            houseStatistic = StatisticProvider.getHouseStatistic(i);
            showDownloader = new ShowDownloader(i);
            show = showDownloader.getShows();
            noOfShow = showDownloader.getNoOfShows();
    %>
    <br>
    <h3>House <%=i%></h3>
    No. of Available Seats: <%=houseStatistic.getAvailableSeats()%><br>
    Ticket Price in average: <%=houseStatistic.getPriceInAverage()%><br><br>
    
    <b>No. of Shows: </b> <%=houseStatistic.getShowsInTotal()%><br>
    This Year: <%=houseStatistic.getShowsInYear()%><br>
    This Month: <%=houseStatistic.getShowsInMonth()%><br>
    Today: <%=houseStatistic.getShowsInDay()%><br><br>

    <% if (noOfShow>0) { %>
    <table>
      <tr>
        <th>Show Time&nbsp;</th>
        <th>&nbsp;Movie Name&nbsp;</th>
        <th>&nbsp;Tickets Sold&nbsp;</th>
        <th>&nbsp;Revenue&nbsp;</th>
      </tr>
    <% for (int j = 0; j < noOfShow; j++) {
            showStatistic = StatisticProvider.getShowStatistic(show[j]);
    %>
     <tr>
        <td><%=show[j].getTimeString()%>&nbsp;</td>
        <td>&nbsp;<%=show[j].getMovieName()%>&nbsp;</td>
        <td>&nbsp;<%=showStatistic.getTickets()%>&nbsp;</td>
        <td>&nbsp;<%=showStatistic.getRevenue()%>&nbsp;</td>    
     </tr>
    <% }%>
    </table>
    <% }}%>
    </body>
</html>